 |
 |
 |
 |
#310935 - 07/30/06 03:36 AM
[7.0] [Beta] PhotoPost featured photos pal
|
Coder
Registered: 07/03/01
Posts: 811
Loc: Berlin, Germany
|
This code is for the pal boxes in Threads7 (beta1). It pull 5 pictures (default random) from the PhotoPost database and display them in pal box. You need to set the database names according to your setup. The script switch the database to make selects from the PhotoPost db and then switch back to Threads database. You need set the cache time (I use 5 minutes) and always build off ind the Threads7 control panel. This script works without a PhotoPost Threads7 integration. It just take the pictures from the db. The original is from Omegatron/Chuck S. for Threads 6.5x require_once("/home/..../ubbthreads/photopost.inc.php");
$pp_db_prefix = "pp_";
function pp_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}
function pp_is_image( $filename ) {
$retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" );
$ext = pp_get_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;
return( $retval );
}
$q_switch = "random";
switch ($q_switch) {
case "most_view":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY c.views DESC";
break;
case "lastest":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY date DESC";
break;
case "random":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY RAND()";
break;
}
$result = mysql_query($query);
$counted = 0; $featured = "";
while ( list($pid, $puser, $puserid, $pcat, $ptitle, $photo, $pviews) = mysql_fetch_array($result)) {
if ( pp_is_image($photo) ) {
$photolen = strlen($photo);
$theext = pp_get_ext($photo);
$photo_name = str_replace( $theext, "", $photo );
$temp_user = $line['userid'];
$thumbtag = "{$full_path}{$pcat}/thumbs/{$photo}";
$mthumb = "<img border=\"0\" src=\"{$data_dir}{$pcat}/thumbs/{$photo}\" alt=\"$thumbtag\" />";
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a>
by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
mysql_select_db ("dbname")or die("Could not select database");
$body = <<<PPPRINT
$featured
PPPRINT;
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#311622 - 10/07/06 01:28 PM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: StanCA]
|
Power User
Registered: 07/01/02
Posts: 71
|
Here is the whole code //* PHP CODE HERE */ // This script should pull 5 random pictures from // PhotoPost and display it. // Please modify the two lines with the databse // connection to your settings. // // The base idea for this script comes from Chuck S. */
// Set it up to your path settings ! require_once("/homepages/1/d118328893/htdocs/clubadventist/photopost/index.php");
// Set this to your PhotoPost db prefix. Default is pp_ $pp_db_prefix = "pp_";
function pp_get_ext( $filename ) { return substr($filename, strrpos($filename,".")); }
function pp_is_image( $filename ) { $retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" ); $ext = pp_get_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) ) $retval = 1;
return( $retval ); }
// // Featured Photos Code // Follow down to End Feature Photos Code //
// which type of images do you want to show $q_switch = "random";
switch ($q_switch) { case "most_view": $query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views FROM {$pp_db_prefix}photos p LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat WHERE c.password = '' ORDER BY c.views DESC"; break; case "lastest": $query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views FROM {$pp_db_prefix}photos p LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat WHERE c.password = '' ORDER BY date DESC"; break; case "random": $query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views FROM {$pp_db_prefix}photos p LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat WHERE c.password = '' ORDER BY RAND()"; break; } $result = mysql_query($query);
$counted = 0; $featured = "";
while ( list($pid, $puser, $puserid, $pcat, $ptitle, $photo, $pviews) = mysql_fetch_array($result)) { if ( pp_is_image($photo) ) { $photolen = strlen($photo); $theext = pp_get_ext($photo); $photo_name = str_replace( $theext, "", $photo );
$temp_user = $line['userid']; $thumbtag = "{$full_path}{$pcat}/thumbs/{$photo}"; $mthumb = "<img border=\"0\" src=\"{$data_dir}{$pcat}/thumbs/{$photo}\" alt=\"$thumbtag\" />";
// One box for each feature $featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1"> <a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a> <br />by {$puser} </td></tr>
PPPRINT;
$counted++; }
if ( $counted == 5 ) break; } mysql_free_result($result);
// change the dbname to your ubb7 database name // we need to switch back to Threads7 database mysql_select_db ("db177660228")or die("Could not select database");
$body = <<<PPPRINT $featured PPPRINT; /* BODY HERE */ $body = <<<EOF EOF;
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#311647 - 10/10/06 03:46 PM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: Zarzal]
|
Power User
Registered: 07/01/02
Posts: 71
|
I am not the fluent in php, or pretty much anything these dasy (ask my kids  ) How far back does that path go?? should it be /homepages/1/d118328893/htdocs/clubadventist/photopost.inc.php or /clubadventist/photopost.inc.php? Can not get either one to work I copy and paste the db name from my control panel in my forums, in the end line.. Yet it comes back and says db not found "Could not select database" which comes from the end of the php code.. photopost in ins /clubadventist/photopost/ I would have thought photopost.inc.php would have been in the /photopost/ folder. there is a 'inc_photopost.php' in the photopost folder.... Am using photopost 5.5 Thanks for your kind patience... Stan
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#312467 - 01/02/07 02:47 AM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: AllenAyres]
|
Lurker
Registered: 09/12/06
Posts: 6
|
Allen.. I confim they aren't showing up on your site using I.E. here too. I got Zarzal's code to work on my site (UBB.t V7.0.2 & PP V5.6.2) by removing the code at the bottom that asks for the ubb database: mysql_select_db ("dbname")or die("Could not select database");
So the end of my content island code looks like this: PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
/* DO NOT CHANGE THE LINE BELOW */
$body = <<<PPPRINT
$featured
PPPRINT;
EOF;
/* DO NOT CHANGE THE LINE ABOVE */ Also note the spelling error in the script "lastest" should be "latest". In addition to the default "random", "latest" works, but "most_view" does not. I haven't played with it to determine why. I also had to uploaded and modify the text file Zarzal posted earlier in the thread, and saved it in the PP directory as photopost.inc.php. This appears to be a file that was present in an earlier version of PP, but is not present in the latest download. inc-photopost.php appears to have much of the same code as Zaral's script.. but I was not able to figure out a way to make it work (with my very limited PHP skills). And lastly, I set the cache to '3' on the content island to have it rebuild the random set of images every 3 minutes. Anyway, the result is a pretty clean sidebar box which only shows the user name under each image. (your implementation has a link to the user's gallery, how many images they have and how many comments). Have a look on my site to see the result. The only other buggy behavior I've found (and haven't yet figured it out) is the sidebar sometimes pulls random images from categories that only have copied images in them (admin copied to a feature category). In those cases, there is no thumbail in the category to pull.. so a red-X appears. Not sure if this is an issue with PP or the PAL script. You won't run into the problem unless you've set up some Admin/Mod only categories in PP (or other similar categories) that only have images that are copied into them from other categories. My "SS Exhibit" category is an example of this. Let me know if you need more info. Oh.. and thanks Zarzal!
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#313268 - 02/25/07 02:37 PM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: Basil Fawlty]
|
Journeyman
Registered: 10/30/01
Posts: 135
Loc: New Mexico
|
Here is everything I have in my custom portal box:
require_once("/home/mysite/public_html/bcforum/includes/photopost.inc.php");
$pp_db_prefix = "pp_";
function pp_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}
function pp_is_image( $filename ) {
$retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" );
$ext = pp_get_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;
return( $retval );
}
$q_switch = "random";
switch ($q_switch) {
case "most_view":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY c.views DESC";
break;
case "lastest":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY date DESC";
break;
case "random":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY RAND()";
break;
}
$result = mysql_query($query);
$counted = 0; $featured = "";
while ( list($pid, $puser, $puserid, $pcat, $ptitle, $photo, $pviews) = mysql_fetch_array($result)) {
if ( pp_is_image($photo) ) {
$photolen = strlen($photo);
$theext = pp_get_ext($photo);
$photo_name = str_replace( $theext, "", $photo );
$temp_user = $line['userid'];
$thumbtag = "{$full_path}{$pcat}/thumbs/{$photo}";
$mthumb = "<img border=\"0\" src=\"{$data_dir}{$pcat}/thumbs/{$photo}\" alt=\"$thumbtag\" />";
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a>
by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
mysql_select_db ("MyDBNAME IS HERE")or die("Could not select database");
$body = <<<PPPRINT
$featured
PPPRINT;
/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
Body of the custom box here
EOF;
/* DO NOT CHANGE THE LINE ABOVE */
When I try to save it, I get unxepected $END at line...blah blah (see previos post).
Edited by Basil Fawlty (02/25/07 02:38 PM)
_________________________
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#313281 - 02/26/07 08:58 AM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: AllenAyres]
|
Journeyman
Registered: 10/30/01
Posts: 135
Loc: New Mexico
|
Can you post a link to the page throwing the error? Hi Allen! Well, to be honest, I seem to have fixed that particular error (I think it was an extra space after the EOF;) Anyway, that's the good news. The bad news is, When I put that custom Pal on my portal, the box shows up with only the title header but nothing in it. Here is what I currently have in that Custom Pal Box:
require_once("/home/mysite/public_html/forum/photopost/photopost.inc.php");
$pp_db_prefix = "pp_";
function pp_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}
function pp_is_image( $filename ) {
$retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" );
$ext = pp_get_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;
return( $retval );
}
$q_switch = "random";
switch ($q_switch) {
case "most_view":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY c.views DESC";
break;
case "lastest":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY date DESC";
break;
case "random":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY RAND()";
break;
}
$result = mysql_query($query);
$counted = 0; $featured = "";
while ( list($pid, $puser, $puserid, $pcat, $ptitle, $photo, $pviews) = mysql_fetch_array($result)) {
if ( pp_is_image($photo) ) {
$photolen = strlen($photo);
$theext = pp_get_ext($photo);
$photo_name = str_replace( $theext, "", $photo );
$temp_user = $line['userid'];
$thumbtag = "{$full_path}{$pcat}/thumbs/{$photo}";
$mthumb = "<img border=\"0\" src=\"{$data_dir}{$pcat}/thumbs/{$photo}\" alt=\"$thumbtag\" />";
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}showphoto.php?photo={$pid}">$mthumb</a>
by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
mysql_select_db ("threadsv7")or die("Could not select database");
$body = <<<PPPRINT
$featured
PPPRINT;
$body = <<<EOF
EOF;
I'm using the photopost.inc.php file that Zarzal (I think) posted as a text file and edited to point to my photopost DB. I guess its working since I'm not getting an error that it can't connect to the DB. I am not getting any error, but all I get when I place the pal on the Portals page is the header and the box itself is empty. I'm running Threads 7.1(Beta 5) and Photopost 5.62 and its running in the "integrated" mode with my Threads. Any ideas? Thanks, Basil
Edited by Basil Fawlty (02/26/07 09:00 AM)
_________________________
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#313344 - 03/03/07 09:57 AM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: Cuervo]
|
Journeyman
Registered: 10/30/01
Posts: 135
Loc: New Mexico
|
Has anyone got this working with 7.1 and PP 5.62
I have it working with 7.1 and PP 5.62 (integrated). I will try to provide as must information as possible. First, I am using Imagemagik instead of GD in my PP. I don't know if that makes any difference, but thought I'd mention it. Ok, here is exactly, in total, what I have in my Custom PAL (I've just changed some minor things for security reasons, but you will want to put your paths and database names in anyway):
require_once("/home/mysite/public_html/forums/photopost/inc_photopost.php");
$pp_db_prefix = "pp_";
function pp_get_ext( $filename ) {
return substr($filename, strrpos($filename,"."));
}
function pp_is_image( $filename ) {
$retval = 0;
$mediatypes = array( ".jpg", ".gif", ".png", ".bmp" );
$ext = pp_get_ext( $filename );
if ( in_array(strtolower($ext), $mediatypes) )
$retval = 1;
return( $retval );
}
$q_switch = "lastest";
switch ($q_switch) {
case "most_view":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY c.views DESC";
break;
case "lastest":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY date DESC";
break;
case "random":
$query = "SELECT p.id,p.user,p.userid,p.cat,p.title,p.bigimage,p.views
FROM {$pp_db_prefix}photos p
LEFT JOIN {$pp_db_prefix}categories c ON c.id=p.cat
WHERE c.password = ''
ORDER BY RAND()";
break;
}
$result = mysql_query($query);
$counted = 0; $featured = "";
while ( list($pid, $puser, $puserid, $pcat, $ptitle, $photo, $pviews) = mysql_fetch_array($result)) {
if ( pp_is_image($photo) ) {
$photolen = strlen($photo);
$theext = pp_get_ext($photo);
$photo_name = str_replace( $theext, "", $photo );
$temp_user = $line['userid'];
$thumbtag = "{$full_path}{$pcat}/thumbs/{$photo}";
$mthumb = "<img border=\"0\" src=\"{$data_dir}{$pcat}/thumbs/{$photo}\" alt=\"$thumbtag\" />";
$featured .= <<<PPPRINT
<tr align="center"><td align="center" class="alt-1">
<a href="{$url_path}/showphoto.php?photo={$pid}">$mthumb</a><br>
by {$puser}
</td></tr>
PPPRINT;
$counted++;
}
if ( $counted == 5 ) break;
}
mysql_free_result($result);
mysql_select_db ("threads")or die("Could not select database");
$body = <<<PPPRINT
$featured
PPPRINT;
Notice that I am pointing to inc_photopost.php in the "Require_Once" statement above. This is a file that now comes with PP 5.62. Within the file inc_photopost.php you will want to uncomment the database lines near the top of the file like this:
$link = mysql_connect ("localhost", "usernam", "password") or die('I cannot connect to the database.');
mysql_select_db ("photopost")or die("Could not select photopost database");
Be sure to edit to reflect YOUR user name and password for the PP database. Also, make sure the "photopost" database name is what you are using in the mysql_select_db statement. Not also, you can change this line: // which type of images do you want to show $q_switch = "lastest"; (Yes, I know it is mispelled) you can replace "lastest" with "random" or "most_view" depending on what category of images you want to pull from the PP database. I hope this helps. It works fine for me, Basil
_________________________
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#313346 - 03/03/07 10:16 AM
Re: Beta [7.0] PhotoPost featured photos pal
[Re: Basil Fawlty]
|
User
Registered: 11/10/01
Posts: 29
|
Basil, Thanks for getting back to this post so soon! Well, I am using GD2 so I too am not sure if that matters. I did get it working finally. I used Allen's post from page one. I would post my inc_features2.php but it has a copyright in it and I don't want to get in any trouble on this forum for posting it. But, if you follow Allen's post to the letter you will get it working. The is one small difference on my install. Since my PP is integrated with my ubbt I didn't have to set any of the parameters for my database. So I DIDN'T uncomment any lines of code. My issue with the black thumbnails was fixed by adding a trailing / to the data path in my photopost config. This is located on the "edit integration" page of the admin section. The field is URL to your PhotoPost DATA directory and for me to get the thumbnails to work I had to edit the field to this http://forums.yourdomain.com/photopost/data/ So it all works now! Thanks for the help!
Edited by Cuervo (03/03/07 10:35 AM)
_________________________
-Cuervo zOMG and oNOES
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#313364 - 03/04/07 08:42 AM
Re: [7.0] [Beta] PhotoPost featured photos pal
[Re: Zarzal]
|
User
Registered: 11/10/01
Posts: 29
|
Well I'm onto something else with this mod. I was trying to figure out how to add the more photos link that reloads the random photo when you click it. So far, which isn't much I have figured out this. It appears that this code located in the showphoto.php file $prevajax = "« <a title=\"{$Globals['pp_lang']['morephotos']}\" href=\"javascript:sendPhotoReq('$npid','$cat','$photo','$limit','$sortby','$sortdir','$sorttime','$ppuser');\">{$Globals['pp_lang']['more']}</a> ·";
}
and this $nextajax = "· <a title=\"{$Globals['pp_lang']['morephotos']}\" href=\"javascript:sendPhotoReq('$npid','$cat','$photo','$limit','$sortby','$sortdir','$sorttime','$ppuser');\">{$Globals['pp_lang']['more']}</a> »";
}
are the parts that handle the more photos commands but where this would get plug into the inc_feature2.php and if that would work are beyond me. Anyone have anyideas on this?
_________________________
-Cuervo zOMG and oNOES
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|